package com.zhenmyan.secdeal.rabbitmq;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * description:
 *
 * @author 颜真明
 * @date 2023/5/15  5:40
 */
@Service
@Slf4j
public class MQFanoutSender {

    @Resource
    private RabbitTemplate rabbitTemplate;

    private static final String FANOUT_EXCHANGE = "fanout_exchange";

    /**
     * fanout模式
     *
     * @param msg
     */
    public void send(Object msg) {
        log.info("Fanout模式发送消息：" + msg);
        rabbitTemplate.convertAndSend(FANOUT_EXCHANGE,"", msg);
    }

}
